package com.py.wemedia.controller.v1;

import com.py.model.common.dtos.ResponseResult;
import com.py.model.wemedia.dtos.WmMaterialDto;
import com.py.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2022/11/10 9:48
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    public ResponseResult upload(MultipartFile multipartFile){
        return wmMaterialService.upload(multipartFile);
    }

    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto dto){
        return wmMaterialService.list(dto);
    }

    /**
     * 删除素材图片
     * @param materialId
     * @return
     */
    @GetMapping("/del_picture/{materialId}")
    public ResponseResult delPicture(@PathVariable int materialId){
        return wmMaterialService.delPicture(materialId);
    }
}